<template>
  <h1>猜数字</h1>
  <input type="text" v-model="num1" placeholder="请输入要猜的数字">
  <button @click="guess">猜一次</button>
  <h3>小提示:{{ result }}</h3>
</template>

<script setup>
import {ref} from "vue";

let num=parseInt(Math.random()*100+1);
const num1 = ref('');
const result = ref('');
console.log(num);
const guess = () => {
  if(num1.value<num){
    result.value="猜小了";
  }else if(num1.value>num){
    result.value="猜大了";
  }else{
    result.value="恭喜你猜对了";
  }
}
</script>

<style scoped>

</style>